#ifndef __TCPSERVER_H
#define __TCPSERVER_H

#include "Mylogger.hh"
#include "Acceptor.h"
#include "EventLoop.h"
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;

using TcpConnectionPtr = shared_ptr<TcpConnection>;
class TcpServer
{
using TcpConnectionCallback = function<void(const TcpConnectionPtr&)>;
public:
    TcpServer(const string & ip,unsigned short port);
    ~TcpServer();
    void start();
    void stop();
    void setAllCallback(TcpConnectionCallback && onConnection,
                        TcpConnectionCallback && onMessage, 
                        TcpConnectionCallback && onClose);
private:
    Acceptor _acceptor;
    EventLoop _loop;
};

#endif